<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jspf/must/basePath.jspf" %>
<!--后台UI组件Start-->
<%@include file="/WEB-INF/jspf/zj/ligerui/LigerUI.jspf" %>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>日活动</title>
        <script src="dc_manager/base/scheme/combo/fl/lookup/comboflLookUp.js" type="text/javascript"></script>
        <script src="dc_manager/base/scheme/promotions/js/promotionsDay.js" type="text/javascript"></script>
        <script>
            $(function () {
                GRID = $("#divID_GRID").ligerGrid({
                    columns: [
                        {display: '活动日期', name: 'promotion_date', type: 'date', width: 100, editor: {type: 'date'}}
                        , {display: '活动价', name: 'promotion_price', width: 60, align: 'left', type: 'float', editor: {type: 'float'}}
                        , {display: '活动数量', name: 'promotion_number', width: 60, align: 'left', type: 'float', editor: {type: 'float'}}
                        , {display: '食物ID', name: 'food_id', hide: true}
                        , {display: '名称', name: 'food_name', width: 130, align: 'left'}
                        , {display: '编码', name: 'food_code', width: 110, align: 'left', editor: {type: 'text'}}
                        , {display: '原价', name: 'food_price', width: 60, align: 'left', editor: {type: 'text'}}//带出食物档案的价格。可以再次调整
                        , {display: '单位ID', name: 'unit_id', hide: true}
                        , {display: '单位', name: 'unit_name', width: 40, align: 'left'}
                        , {display: 'img', name: 'food_img', hide: true}
                    ], enabledEdit: true
//                    , onBeforeEdit: f_edit1
                    , onAfterEdit: f_edit2
                    , usePager: false
                    , url: ''
                    , dateFormat: "yyyy-MM-dd"
                    , width: '750px'
                    , height: '97%'
                });
                $("#toptoolbar").ligerToolBar({items: [
                        {text: '保存', click: save}
                        , {line: true}
                        , {text: '增加', click: add}
                        , {line: true}
                        , {text: '移除', click: dell}
                        , {line: true}
                        //                        , {text: '复制BOM', click: copyBOM}
                    ]});
            });
            function save() {
                var GD = GRID.getData();
                var x = "";
                for (var i = 0; i < GD.length; i++) {
                    x = x + "," + getMyjsonDate(GD[i]);
                }
                x = x.substring(1);
                post_json("weixinkeji/dev/dc/base/scheme/promotions/a/add.imy"
                        , {
                            list: x
                        }
                , 400, 200);
                return false;

                function getMyjsonDate(x) {

                    return "{\"promotion_price\":\"" + x.promotion_price + "\""
                            + ",\"promotion_date\":\"" + dateStamp2String(x.promotion_date) + "\""
                            + ",\"promotion_number\":\"" + x.promotion_number + "\""
                            + ",\"promotion_now_number\":\"" + x.promotion_number + "\""
                            + ",\"food_id\":\"" + x.food_id + "\""
                            + ",\"food_name\":\"" + x.food_name + "\""
                            + ",\"food_code\":\"" + x.food_code + "\""
                            + ",\"food_price\":\"" + x.food_price + "\""
                            + ",\"food_img\":\"" + x.food_img + "\""
                            + ",\"unit_id\":\"" + x.unit_id + "\""
                            + ",\"unit_name\":\"" + x.unit_name + "\""
                            + "}";
                }
            }
            function add() {
                GRID.endEdit();
                GRID.addRow({food_number: 1});
            }
            function dell() {
                var row = GRID.getSelectedRow();
                if (null != row) {
                    GRID.endEdit();
                    GRID.deleteRow(row);
                }
            }
            function f_edit2(e) {
                f_add_promotionsDay(e.column.name, e.value);
            }
        </script>
    </head>
    <body>
        <div>
            <!--            <div id="Combo_divID" style="float:left">
                            <form name="form" method="post"  id="Combo_formID">
                                <table cellpadding="0" cellspacing="0" class="l-table-edit" >
                                    <tr>
                                        <td align="right" class="l-table-edit-td">分类:</td>
                                        <td align="left" class="l-table-edit-td" style="width:160px">
                                            <input type="text" name="flid" id="flid2" validate="{required:true,minlength:1}" maxlength="26" ltype="text"/>
                                        </td><td align="left"></td>
                                    </tr>
                                    <tr>
                                        <td align="right" class="l-table-edit-td">编码:</td>
                                        <td align="left" class="l-table-edit-td" style="width:160px">
                                            <input type="text" name="combo_code" id="combo_code" validate="{required:true,minlength:1}" maxlength="26" ltype="text"/>
                                        </td><td align="left"></td>
                                    </tr>
                                    <tr>
                                        <td align="right" class="l-table-edit-td">名称:</td>
                                        <td align="left" class="l-table-edit-td" style="width:160px">
                                            <input type="text" name="combo_name" id="combo_name" validate="{required:true,minlength:1}" maxlength="26" ltype="text"/>
                                        </td><td align="left"></td>
                                    </tr>
                                    <tr>
                                        <td align="right" class="l-table-edit-td">启用:</td>
                                        <td align="left" class="l-table-edit-td" style="width:160px">
                                            <select name="combo_style" id="combo_style">
                                                <option value="1">是</option>
                                                <option value="0">否</option>
                                            </select>
                                        </td><td align="left"></td>
                                    </tr>
                                    <tr>
                                        <td align="right" class="l-table-edit-td">价格:</td>
                                        <td align="left" class="l-table-edit-td" style="width:160px">
                                            <input type="text" name="combo_price" id="combo_price" validate="{required:true,minlength:1}" maxlength="11" ltype="text"/>
                                        </td><td align="left"></td>
                                    </tr>
                                    <tr>
                                        <td align="right" class="l-table-edit-td">每单限购:</td>
                                        <td align="left" class="l-table-edit-td" style="width:160px">
                                            <input type="text" name="combo_number" id="combo_number" validate="{required:true,minlength:1}" maxlength="3" ltype="text"/>
                                        </td><td align="left"></td>
                                    </tr>
                                    <tr>
                                        <td align="right" class="l-table-edit-td">备注:</td>
                                        <td align="left" class="l-table-edit-td" style="width:160px">
                                            <input type="text" name="combo_info" id="combo_info" validate="{required:true,minlength:1}" maxlength="26" ltype="text"/>
                                        </td><td align="left"></td>
                                    </tr>
                                                            <tr>
                                                                <td align="right" class="l-table-edit-td">清单金额:</td>
                                                                <td align="left" class="l-table-edit-td" style="width:160px">
                                                                    <input type="text" name="combo_listPriceSum" id="combo_listPriceSum" validate="{required:true,minlength:1}" maxlength="0" ltype="text"/>
                                                                </td><td align="left"></td>
                                                            </tr>
                                    <tr style=" height: 100px;">
                                        <td></td>
                                        <td>
                                            <input type="submit" value="提交" id="Button1" class="l-button l-button-submit" /> 
                                        </td><td></td>
                                    </tr>
                                </table>
                                <br />
                            </form>
                        </div>-->
            <div  style="float:left">
                <div id="toptoolbar"></div> 
                <div id="divID_GRID" style="margin:0; padding:0"></div>
            </div>
        </div>
    </body>
</html>
